<template>
	<u-overlay :show="show" @click="close">
		<view class="warp">
			<view class="warp2">
				<view class="rect" @tap.stop>
					<view class="front" :animation="animationData" style="transform: scale(0,0) rotateY(90deg);">
						<u-icon @click="close" name="close-circle-fill" size="23" color="#C1C4CA" class="close">
						</u-icon>
						<view class="text-center title bold m-b-10 m-t-5">
							签到成功，获得 <text class="green"> {{signInData.stone}} </text>元石
						</view>
						<view class="text-center f-xs">
							已连续签到 {{signInData.continue}} 天，明日签到 +{{signInData.tomorrowStone}} 元石
						</view>
						<view class="sign-image text-center">
							<image src="../../../static/yuanshi.png" mode=""></image>
						</view>
						<u-button color="#000000" size="large" shape="circle" @click="toCalendar">
							<text class="bold f-base">前往签到中心 获取更多元石</text>
						</u-button>
					</view>
				</view>
			</view>
		</view>
	</u-overlay>
</template>

<script>
	export default {
		props: {
			show: {
				type: Boolean,
				default: false
			},
			signInData: Object
		},
		data() {
			return {
				animation: {},
				animationData: {}
			}
		},
		mounted() {
			this.$nextTick(() => {
				this.turnAnimation()
			})
		},
		methods: {
			close() {
				this.$emit('close')
			},
			toCalendar() {
				uni.navigateTo({
					url: '/pages/user/calender'
				})
				this.close()
			},
			// 翻转动画
			turnAnimation() {
				var animation = uni.createAnimation({
					duration: 1000,
					timingFunction: 'ease-in', //linear 全程匀速运动  ease 动画以低速开始，然后加快，在结束前变慢
				})
				this.animation = animation
				animation.scale(0.5, 0.5).rotateY(-60).step()
				animation.scale(0.75, 0.75).rotateY(60).step({
					duration: 500
				})
				animation.scale(1, 1).rotateY(0).step({
					duration: 500
				})
				this.animationData = animation.export()
			}
		}
	}
</script>

<style scoped lang="scss">
	.warp {
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.1);
		background: url(https://cdn3.relaverse.cn/appfile/calendar-light4.png) no-repeat;
		background-size: cover;

		.warp2 {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			height: 100%;
			background-color: rgba(0, 0, 0, 0.1);
			background: url(https://cdn3.relaverse.cn/appfile/calendar-light5.png) no-repeat;
			background-size: cover;
		}

		.rect {
			width: 590rpx;
			height: 640rpx;
			perspective: 1000;
			border-radius: 20rpx;
			transform-style: preserve-3d;
			position: relative;
			z-index: 99999;

			// display: none;
			.front {
				position: absolute;
				left: 0;
				right: 0;
				top: 0;
				bottom: 0;
				transition: all 1s;
				background-color: #fff;
				padding: 60rpx;
				border-radius: 20rpx;
				box-sizing: border-box;
				z-index: 99999;

				.close {
					position: absolute;
					top: 11rpx;
					right: 11rpx;
				}

				.title {
					font-size: 20px;

					.green {
						color: #20C566;
					}
				}

				.sign-image {
					margin-top: 60rpx;

					image {
						width: 233rpx;
						height: 233rpx;
					}
				}
			}

			.back {
				position: absolute;
				left: 0;
				right: 0;
				top: 0;
				bottom: 0;
				transition: all 1s;
				background-color: #fff;
				padding: 60rpx;
				border-radius: 20rpx;
				box-sizing: border-box;
			}
		}
	}
</style>
